package com.iiapk.remind.server.domain.mail;

import java.util.List;

import com.iiapk.core.AbstractSimpleSpringRepository;

/**
 * 邮件持久化操作 
 * @author Atomic
 */
public class MailRepository extends AbstractSimpleSpringRepository {

	public int save(MailEntity entity) {
		String sql = "INSERT INTO re_mailenties(remindId,sendDate,context,target) VALUES(:remindId,:sendDate,:context,:target)";

		return super.saveByNamed(sql, entity);
	}

	/**
	 * 根据发送时间找到今天该发送的邮件 
	 */
	public List<MailEntity> findTodayMail() {
		
		String sql = "SELECT * FROM re_mailenties WHERE DATE(sendDate)= CURRENT_DATE()";
		return super.findAll(sql, MailEntity.class);
	}
}
